import 'package:flutter/material.dart';
import './router/index.dart';
// 状态管理
import 'package:provider/provider.dart';
import 'model/goods_manage.dart';

///loading动画
import 'package:flutter_easyloading/flutter_easyloading.dart';

// 设置loading，其他配置见官方文档
void configLoading() {
  EasyLoading.instance
    // ..displayDuration = const Duration(milliseconds: 2000)  // 加载时间
    ..indicatorType = EasyLoadingIndicatorType.circle // 加载类型
    ..loadingStyle = EasyLoadingStyle.light // 加载样式
    ..indicatorSize = 45.0 // 大小
    ..maskType = EasyLoadingMaskType.none // 遮罩
    ..userInteractions = true // 使用单例模式
    ..toastPosition = EasyLoadingToastPosition.bottom
    ..dismissOnTap = false; // 指示器结束的点击时间
}

void main() {
  runApp(
    MultiProvider(providers: [
      ChangeNotifierProvider(create: (_) => GoodsManageModel()),
    ], child: const MyApp()),
  );
  configLoading();
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: '进出货管理',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(
          primary: const Color(0xFF3084FC),
          seedColor: const Color.fromARGB(255, 255, 255, 255),
        ),
        useMaterial3: true,
        scaffoldBackgroundColor: const Color(0xFFf5f5f5),
        textTheme: const TextTheme(
          bodyMedium: TextStyle(
              decoration: TextDecoration.none,
              color: Color(0xFF1E1E1E),
              fontWeight: FontWeight.w500),
        ),
        appBarTheme: const AppBarTheme(
            color: Colors.white,
            titleTextStyle: TextStyle(
                color: Color(0xFF1E1E1E),
                fontWeight: FontWeight.bold,
                fontSize: 18)),
      ),
      debugShowCheckedModeBanner: false,
      onGenerateRoute: RouterTable.onGenerateRoute,
      builder: EasyLoading.init(),
    );
  }
}
